<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">叫号器列表</div>
                </div>
                <div class="widget-body am-fr">
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a class="am-btn am-btn-default am-btn-success am-radius"
                                       href="<?= url('shop.calling/add') ?>">
                                        <span class="am-icon-plus"></span> 新增
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                            <tr>
                                <th>编号ID</th>
                                <th>所属门店</th>
                                <th>设备名称</th>
								<th>云端编号</th>
                                <th>设备音量</th>
                                <th>到账提醒</th>
                                <th>订单提醒</th>
								<th>网络状态</th>
                                <th>设备状态</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
									<td class="am-text-middle">
                                        <p class="item-title"><?= $item['calling_id'] ?></p>
                                    </td>
                                    <td class="am-text-middle"><?= $item['shop']['shop_name'] ?></td>
                                    <td class="am-text-middle"><?= $item['calling_name'] ?></td>
                                    <td class="am-text-middle"><?= $item['device_name'] ?></td>
                                    <td class="am-text-middle">
                                        <span class="<?= $item['volume']['value'] > 1 ? 'x-color-green'
                                            : 'x-color-red' ?>">
                                        <?= $item['volume']['text'] ?>
                                        </span> 
                                    </td>
                                    <td class="am-text-middle"><?= $item['is_pay']['text'] ?></td>
                                    <td class="am-text-middle"><?= $item['is_new']['text'] ?></td>
									<td class="am-text-middle">
                                         <span class="<?= $item['is_open']['status'] == '上线' ? 'x-color-green'
                                            : 'x-color-red' ?>">
                                        <?= $item['is_open']['status'] ?>
                                        </span> 
                                    </td>
                                    <td class="am-text-middle">
                                        <span class="j-open am-badge x-cur-p  <?= $item['is_open']['value'] == 1 ? ' am-badge-success'
                                            : ' am-badge-warning' ?>" 
                                             data-ids="<?= $item['calling_id'] ?>"
                                             data-status="<?= $item['is_open']['value'] ?>">
                                        <?= $item['is_open']['text'] ?>
                                        </span>
                                    </td>
                                    <td class="am-text-middle"><?= $item['create_time'] ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="<?= url('shop.calling/edit',
                                                ['calling_id' => $item['calling_id']]) ?>">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="item-del tpl-table-black-operation-del"
                                               data-ids="<?= $item['calling_id'] ?>">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="11" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {

        // 切换开关状态
        $('.j-open').click(function () {
            var data = $(this).data();
            var msg = '确定要'+(parseInt(data.status) === 1 ? '关闭' : '开启')+'该设备？';
            var url = "<?= url('shop.call/open') ?>";
            $('.j-open').del('calling_id', url,msg);
        });

        // 删除元素
        var url = "<?= url('shop.calling/delete') ?>";
        $('.item-del').del('calling_id', url);

    });
</script>

